<template>
	<el-dialog title="商超退款" v-model="dialogVisible" @close="dialogFormVisible" :close-on-click-modal="false"
		:close-on-press-escape="false" width="600px">
         
		<el-text class="mx-1">订单号：{{ super_refund_obj.order_no }}</el-text>
		<br>
		<el-text class="mx-1">订单金额：￥{{ super_refund_obj.order_price }}</el-text>

		<el-form size="small" :model="form" :rules="formRules" ref="form" style="margin-top: 20px;">
			<el-form-item label="退款金额" prop="super_user_refund_money">
                <el-input v-model="super_refund_obj.super_user_refund_money" placeholder="请输入退款金额"></el-input>
            </el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="dialogFormVisible">取 消</el-button>
			<el-button type="primary" @click="submit_super_refund()" :loading="loading">确 定</el-button>
		</template>

	</el-dialog>
</template>

<script>
	import {
		addSuperRefunds
	} from '@/api/order.js';

export default {
	components: {

	},
	data() {
		return {
			form: {
				image_id: '',
			},
			formRules: {
				image_id: [{
					required: true,
					message: '请上传分类图片',
					trigger: 'blur',
				}, ],
			},
			/*左边长度*/
			formLabelWidth: '120px',
			/*是否显示*/
			dialogVisible: false,
			loading: false,
			/*是否上传图片*/
			isupload: false,
			// super_refund_obj: {},
		};
	},
	props: ['open_refunds','super_refund_obj'],
	created() {
		this.dialogVisible = this.open_refunds;
	},
	methods: {
		/*提交退款*/
		submit_super_refund() {
			let self = this;
			var data = {
                order_no: self.super_refund_obj.order_no,
                super_user_refund_money: self.super_refund_obj.super_user_refund_money,
            };
			console.log(2234,data);
			self.$refs.form.validate((valid) => {
				if (valid) {
					self.loading = true;
					addSuperRefunds(data).then((res) => {
						self.loading = false;
						ElMessage({
							message: '提交退款成功',
							type: 'success',
						});
						self.dialogFormVisible(true);
					}).catch((error) => {
						self.loading = false;
					});
				}
			});
		},

		/*关闭弹窗*/
		dialogFormVisible(e) {
			if (e) {
				this.$emit('closeDialog', {
					type: 'success',
					openDialog: false,
				});
			} else {
				this.$emit('closeDialog', {
					type: 'error',
					openDialog: false,
				});
			}
		},
		/*上传*/
		openUpload(e) {
			this.type = e;
			this.isupload = true;
		},

	},
};
</script>

<style scoped>
	.img {
		margin-top: 10px;
	}
</style>